We want to split the data into deciles on each data column. First, we’ll filter by the top decile for retailer concentration and retailer count. From there, we will count decile number as an integer to add across a tract. That will make a score for how extreme a tract’s case is for all demographic data points. Taking the top ten scoring tracts for every state will get us started narrowing down the worst hit tracts for reporters to focus on.
## [[1]]
## # A tibble: 20 × 1
## geoid
## <chr>
## 1 04013113800
## 2 04013093104
## 3 04013421304
## 4 04019003502
## 5 04019003506
## 6 04013109001
## 7 04013113301
## 8 04013319801
## 9 04013104501
## 10 04013092802
## 11 04013092900
## 12 04023966401
## 13 04013114800
## 14 04027000302
## 15 04019004122
## 16 04013114500
## 17 04027000700
## 18 04013116500
## 19 04013061402
## 20 04019002300
##
## [[2]]
## # A tibble: 30 × 1
## geoid
## <chr>
## 1 04013113800
## 2 04013093104
## 3 04013421304
## 4 04019003502
## 5 04019003506
## 6 04013109001
## 7 04013113301
## 8 04013319801
## 9 04013104501
## 10 04013092802
## # … with 20 more rows
##
## [[3]]
## # A tibble: 33 × 1
## geoid
## <chr>
## 1 04013113800
## 2 04013093104
## 3 04013421304
## 4 04019003502
## 5 04019003506
## 6 04013109001
## 7 04013113301
## 8 04013319801
## 9 04013104501
## 10 04013092802
## # … with 23 more rows
##
## [[4]]
## # A tibble: 53 × 1
## geoid
## <chr>
## 1 04013113800
## 2 04013093104
## 3 04013421304
## 4 04019003502
## 5 04019003506
## 6 04013109001
## 7 04013113301
## 8 04013319801
## 9 04013104501
## 10 04013092802
## # … with 43 more rows
##
## [[5]]
## # A tibble: 70 × 1
## geoid
## <chr>
## 1 04013113800
## 2 04013093104
## 3 04013421304
## 4 04019003502
## 5 04019003506
## 6 04013109001
## 7 04013113301
## 8 04013319801
## 9 04013104501
## 10 04013092802
## # … with 60 more rows
##
## [[6]]
## # A tibble: 83 × 1
## geoid
## <chr>
## 1 04013113800
## 2 04013093104
## 3 04013421304
## 4 04019003502
## 5 04019003506
## 6 04013109001
## 7 04013113301
## 8 04013319801
## 9 04013104501
## 10 04013092802
## # … with 73 more rows
##
## [[7]]
## # A tibble: 103 × 1
## geoid
## <chr>
## 1 04013113800
## 2 04013093104
## 3 04013421304
## 4 04019003502
## 5 04019003506
## 6 04013109001
## 7 04013113301
## 8 04013319801
## 9 04013104501
## 10 04013092802
## # … with 93 more rows
##
## [[8]]
## # A tibble: 123 × 1
## geoid
## <chr>
## 1 04013113800
## 2 04013093104
## 3 04013421304
## 4 04019003502
## 5 04019003506
## 6 04013109001
## 7 04013113301
## 8 04013319801
## 9 04013104501
## 10 04013092802
## # … with 113 more rows
##
## [[9]]
## # A tibble: 143 × 1
## geoid
## <chr>
## 1 04013113800
## 2 04013093104
## 3 04013421304
## 4 04019003502
## 5 04019003506
## 6 04013109001
## 7 04013113301
## 8 04013319801
## 9 04013104501
## 10 04013092802
## # … with 133 more rows
##
## [[10]]
## # A tibble: 163 × 1
## geoid
## <chr>
## 1 04013113800
## 2 04013093104
## 3 04013421304
## 4 04019003502
## 5 04019003506
## 6 04013109001
## 7 04013113301
## 8 04013319801
## 9 04013104501
## 10 04013092802
## # … with 153 more rows
##
## [[11]]
## # A tibble: 183 × 1
## geoid
## <chr>
## 1 04013113800
## 2 04013093104
## 3 04013421304
## 4 04019003502
## 5 04019003506
## 6 04013109001
## 7 04013113301
## 8 04013319801
## 9 04013104501
## 10 04013092802
## # … with 173 more rows
### bind geoids created above to all retailers
all_retailers <- readRDS("../../../data/processed/03_join_retailers/all_geocoded_retailers.rds")
decennial_tracts
## Simple feature collection with 60961 features and 15 fields
## Geometry type: MULTIPOLYGON
## Dimension: XY
## Bounding box: xmin: -124.7631 ymin: 24.5231 xmax: -66.9499 ymax: 49.38436
## Geodetic CRS: NAD83
## # A tibble: 60,961 × 16
## geoid tract county state geometry total_pop retailer_count
## <chr> <chr> <chr> <chr> <MULTIPOLYGON [°]> <dbl> <int>
## 1 04003001501 Cens… Cochi… Ariz… (((-110.3052 31.55428, -… 2612 3
## 2 04005000400 Cens… Cocon… Ariz… (((-111.6136 35.22486, -… 3941 3
## 3 04007000800 Cens… Gila … Ariz… (((-111.1531 33.67711, -… 936 1
## 4 04007000500 Cens… Gila … Ariz… (((-111.3538 34.09197, -… 4788 3
## 5 04007000700 Cens… Gila … Ariz… (((-111.452 33.93377, -1… 1532 2
## 6 04013422102 Cens… Maric… Ariz… (((-111.8746 33.40496, -… 3406 2
## 7 04013422308 Cens… Maric… Ariz… (((-111.8072 33.37893, -… 4211 4
## 8 04013103304 Cens… Maric… Ariz… (((-112.02 33.64056, -11… 3567 5
## 9 04013420706 Cens… Maric… Ariz… (((-111.7536 33.42449, -… 3680 4
## 10 04013319600 Cens… Maric… Ariz… (((-111.9435 33.40738, -… 4682 3
## # … with 60,951 more rows, and 9 more variables: retailer_concentration <dbl>,
## # total <dbl>, pct_white <dbl>, pct_black <dbl>, pct_asian <dbl>,
## # pct_hispanic <dbl>, pct_nhpi <dbl>, pct_two_or_more_races <dbl>,
## # pct_indigenous <dbl>
acs_tracts
## Simple feature collection with 55321 features and 10 fields
## Geometry type: MULTIPOLYGON
## Dimension: XY
## Bounding box: xmin: -124.7408 ymin: 24.5231 xmax: -66.9499 ymax: 49.38436
## Geodetic CRS: NAD83
## # A tibble: 55,321 × 11
## geoid tract county state geometry total_pop count
## <chr> <chr> <chr> <chr> <MULTIPOLYGON [°]> <dbl> <int>
## 1 04013092402 Censu… Marico… Ariz… (((-112.1602 33.5531, -112.… 3453 3
## 2 04013061401 Censu… Marico… Ariz… (((-112.3563 33.43533, -112… 2257 1
## 3 04013092305 Censu… Marico… Ariz… (((-112.2032 33.56727, -112… 4425 4
## 4 04013106300 Censu… Marico… Ariz… (((-112.0652 33.55272, -112… 5023 5
## 5 04013112601 Censu… Marico… Ariz… (((-112.1518 33.46375, -112… 3804 2
## 6 04013104100 Censu… Marico… Ariz… (((-112.1338 33.6176, -112.… 7241 2
## 7 04013109703 Censu… Marico… Ariz… (((-112.2206 33.48446, -112… 3279 1
## 8 04019002703 Censu… Pima C… Ariz… (((-110.9567 32.26125, -110… 3944 2
## 9 04013061402 Censu… Marico… Ariz… (((-112.3579 33.42488, -112… 6184 6
## 10 04019004038 Censu… Pima C… Ariz… (((-110.8409 32.18308, -110… 3069 2
## # … with 55,311 more rows, and 4 more variables: retailer_concentration <dbl>,
## # median_household_income <dbl>, pct_hs_or_below <dbl>, pct_poverty <dbl>
these_polygons_acs <- all_acs_interest_tracts_nation %>%
left_join(acs_tracts) %>%
st_as_sf()
## Joining, by = "geoid"
these_polygons_dec <- all_dec_interest_tracts_nation %>%
left_join(decennial_tracts) %>%
st_as_sf()
## Joining, by = "geoid"
all_retailers <- all_retailers %>%
mutate(joint_longitude = as.numeric(joint_longitude),
joint_latitude = as.numeric(joint_latitude))
retailer_demo_map <- leaflet() %>%
addProviderTiles(providers$Stamen.TonerLite) %>%
addPolygons(data = these_polygons_acs,
color = "blue",
weight = 0.5,
group = "these_polygons_acs",
smoothFactor = 0.2,
fillOpacity = 0.25,
label = paste0(these_polygons_acs$county,": ",
these_polygons_acs$tract," | ",
round(these_polygons_acs$pct_poverty,1),"% in poverty | ",
round(these_polygons_acs$pct_hs_or_below,1)," % with a high school degree or below",
" $",these_polygons_acs$median_household_income)) %>%
addMarkers(data = all_retailers,
~joint_longitude,
~joint_latitude,
label = ~retailer_name,
clusterOptions = markerClusterOptions()
) %>%
addSearchFeatures(
targetGroups = "these_polygons_acs",
options = searchFeaturesOptions(zoom = 10, openPopup = TRUE))
## Warning: sf layer has inconsistent datum (+proj=longlat +datum=NAD83 +no_defs).
## Need '+proj=longlat +datum=WGS84'
## Warning in validateCoords(lng, lat, funcName): Data contains 34353 rows with
## either missing or invalid lat/lon values and will be ignored
retailer_demo_map